<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>question2</h1>
    <script>
        var person=[{"id":1 , "name" :"aaa" , "age":80 , "fatherId" : null},
            {"id":2 , "name" :"bbb" , "age":79 , "fatherId" : null},
            {"id":3 , "name" :"ccc" , "age":50 , "fatherId" : 2},
            {"id":4 , "name" :"ddd" , "age":48 , "fatherId" : 2},
            {"id":5 , "name" :"eee" , "age":24 , "fatherId" : 3},
            {"id":6 , "name" :"fff" , "age":2 , "fatherId" : 5},
            {"id":7 , "name" :"ggg" , "age":52 , "fatherId" : 1},
            {"id":8 , "name" :"hhh" , "age":30 , "fatherId" : 2},
            {"id":9 , "name" :"iii" , "age":33 , "fatherId" : 1},
            {"id":10 , "name" :"jjj" , "age":41 , "fatherId" : 1},
            {"id":11 , "name" :"kkk" , "age":10 , "fatherId" : 9},
            {"id":12 , "name" :"lll" , "age":3 , "fatherId" : 10},
            {"id":13 , "name" :"mmm" , "age":60 , "fatherId" : null},
            {"id":14 , "name" :"nnn" , "age":40 , "fatherId" : 13},
            {"id":15 , "name" :"ooo" , "age":4 , "fatherId" : 15},
            {"id":16 , "name" :"ppp" , "age":15 , "fatherId" : 3},
            {"id":17 , "name" :"qqq" , "age":9 , "fatherId" : 14},
            {"id":18 , "name" :"rrr" , "age":66 , "fatherId" : null},
            {"id":19 , "name" :"sss" , "age":23 , "fatherId" : 18}]
        function des(id) {
            var rst=new Array();
            for (var key of person) {
                if (key.fatherId == id) {
                    rst.push(key.id);
                }
            }
            console.log(rst);

                for(var i=0;i<rst.length;i++){
                    var rrt=new Array();
                    for(var k of person){
                        if(rst[i]==k.fatherId){
                           rrt.push(k.id);
                        }
                    }
                    console.log(rrt);
                }


        }

        des(1);





    </script>
</body>
</html>